$('.identity_button_refuse').click(function(){
	var userid = $('input[name="userid"]').val();
	var licenceid = $('input[name="licenceid"]').val();
	sendLicenceAction('identificationCertificate','JJ',licenceid,userid)
});
$('.identity_button_reject').click(function(){
	var userid = $('input[name="userid"]').val();
	var licenceid = $('input[name="licenceid"]').val();
	sendLicenceAction('identificationCertificate','BH',licenceid,userid)
});
$('.identity_button_adopt').click(function(){
	var userid = $('input[name="userid"]').val();
	var licenceid = $('input[name="licenceid"]').val();
	sendLicenceAction('identificationCertificate','TG',licenceid,userid)
});

$('.business_button_refuse').click(function(){
	var userid = $('input[name="userid"]').val();
	var licenceid = $('input[name="licenceid"]').val();
	sendLicenceAction('businessLicenseAudit','JJ',licenceid,userid)
});

$('.business_button_reject').click(function(){
	var userid = $('input[name="userid"]').val();
	var licenceid = $('input[name="licenceid"]').val();
	sendLicenceAction('businessLicenseAudit','BH',licenceid,userid)
});

$('.business_button_adopt').click(function(){
	var userid = $('input[name="userid"]').val();
	var licenceid = $('input[name="licenceid"]').val();
	sendLicenceAction('businessLicenseAudit','TG',licenceid,userid)
});


$('.foodpermit_button_refuse').click(function(){
	var userid = $('input[name="userid"]').val();
	var licenceid = $('input[name="licenceid"]').val();
	sendLicenceAction('foodSafetyAudit','JJ',licenceid,userid)
});

$('.foodpermit_button_reject').click(function(){
	var userid = $('input[name="userid"]').val();
	var licenceid = $('input[name="licenceid"]').val();
	sendLicenceAction('foodSafetyAudit','BH',licenceid,userid)
});

$('.foodpermit_button_adopt').click(function(){
	var userid = $('input[name="userid"]').val();
	var licenceid = $('input[name="licenceid"]').val();
	sendLicenceAction('foodSafetyAudit','TG',licenceid,userid)
});


function sendLicenceAction(tt,action,licenceid,userid) {
	$.ajaxSetup({
	    headers: {
	        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
	    }
	});
	$.post('/'+tt,{'userid':userid,'status':action,'licenceid':licenceid},function(response){
		if(response.success){
			toastr.success(response.message);
			setTimeout(function(){
				location.href = document.referrer;
			},3000);
		}else{
			toastr.error(response.message);
		}
	},'json');
}